package com.mattgarner.jaddas.node;

import java.net.InetAddress;

import com.mattgarner.jaddas.node.net.Worker;

public class RemoteClient {
	private NodeConfigurationManager nodeConfig;
	private int cliID;
	private InetAddress cliAddress;
	private Worker cliWorkerThread;
	private int cliStatus;
	private int cliType = 0; // CLIENT by default
	
	private String cliStringEncoding;
	private long lastActivityTime; 
	
	// constants
	public final static int COMPRESSION_NONE = 0;
	public final static int COMPRESSION_GZIP = 1;
	public final static int COMPRESSION_LZIP = 2;
	private int compressionMode = COMPRESSION_NONE;
	
	public final static int UNAUTHENTICATED = 0;
	public final static int CONNECTED = 1;
	
	public RemoteClient(int clientID, InetAddress clientAddress, Worker clientWorkerThread) {
		cliID = clientID;
		cliAddress = clientAddress;
		cliWorkerThread = clientWorkerThread;
		
		nodeConfig = NodeConfigurationManager.getInstance();
		cliStringEncoding = nodeConfig.getStringEncoding();
	}
	
	public RemoteClient(Exception dummy) {
		
	}
	
	public final void setClientStatus(int clientStatus) {
		cliStatus =  clientStatus;
	}
	
	public final void setCompressionMode(int algorithm) {
		compressionMode = algorithm;
	}
	
	public final void setLastActivityTime(long time) {
		lastActivityTime = time;
	}
	
	// getter
	public final int getClientStatus() {
		return cliStatus;
	}
	
	public final String getIPAddressString() {
		return cliAddress.toString().replaceAll("/", "");
	}
	
	public final String getStringEncoding() {
		return cliStringEncoding;
	}
	
	public final int getCompressionMode() {
		return compressionMode;
	}
	
	public final int getClientType() {
		return cliType;
	}
	
	public final int getClientID() {
		return cliID;
	}
	
	public final long getLastActivityTime() {
		return lastActivityTime;
	}
}
